#pragma once

#include <cmath>

namespace davmath { class vec3f; }
using namespace davmath;

/* * * * * * * * * *
 * vec3f
 * Author:	David Ogle
 * Date:	03/03/2012
 * 3D Vector of float values
 * * * * * * * * * */

class davmath::vec3f
{
public:

	// Data union
	// Can access the vector components 
	// via array, or member notation
	union {
		float i[3];
		struct { float x, y, z; };
		struct { float r, g, b; };
	};




	// Constructors
	vec3f(void) { toZero(); };
	vec3f(float x, float y, float z) {
		this->x = x;
		this->y = y;
		this->z = z;
	};

	// Destructor
	~vec3f(void) { };


	void			toZero();									// zero vector
	vec3f			inverse()						const;		// inverse						
	float			lengthSquared()					const;		// length-squared
	float			length()						const;		// length. Vector magnitude
	void			normalize();								// Normalize vector

	static vec3f	dot(const vec3f &a, const vec3f &b);		// dot product
	static vec3f	cross(const vec3f &a, const vec3f &b);		// cross product

	inline vec3f	operator-()	const;							// inverse
	inline bool		operator==(const vec3f &src)	const;		// equals
	inline bool		operator!=(const vec3f &src)	const;		// not-equals
	inline vec3f	operator-(const vec3f &src)		const;		// vector subtraction
	inline vec3f	operator+(const vec3f &src)		const;		// vector addition
	inline vec3f	operator*(const vec3f &src)		const;		// vector multiplication
	inline vec3f	operator/(const vec3f &src)		const;		// vector division
	inline void		operator+=(const vec3f &src);				// add-equals
	inline void		operator-=(const vec3f &src);				// subtract-equals
	inline void		operator*=(const vec3f &src);				// multiply-equals
	inline void		operator/=(const vec3f &src);				// divide-equals

	inline vec3f	operator+(const float a)		const;		// scalar addition
	inline vec3f	operator-(const float a)		const;		// scalar subtraction
	inline vec3f	operator*(const float a)		const;		// scalar multiply
	inline vec3f	operator/(const float a)		const;		// scalar divide


};

